// 云函数入口文件
const cloud = require('wx-server-sdk')
//规定一下环境
cloud.init(({
  env:"test-2oth4"
}))

// 云函数入口函数
exports.main = async(event, context) => {
  //拿到前端传来的base64数据
  let {base64Date} = event;
 
  //因为fileContent只支持Buffer格式或者文件流
  return await cloud.uploadFile({
   cloudPath:"image/"+Date.now()+'.png',
   fileContent:Buffer.from(base64Date,"base64"),
  })
}